using AutoMapper;
using Blog.Repository;
using Blog.Service.Api;
using Blog.Service.Api.Output;
using System.Collections.Generic;
using XjjXmm.Infrastructure.Repository;
using XjjXmm.Infrastructure.User;


namespace Blog.Service;



/// <summary>
/// 接口管理
///</summary>
public class ApiService  : CrudService<ApiModel, ApiEntity>, IApiService
{
    private readonly IApiRepository _apiRepository;
    public ApiService(IApiRepository apiRepository, IUser user, IMapper mapper) : base(apiRepository, user, mapper)
    {
        _apiRepository = apiRepository;
    }

    public async Task<List<ApiListOutput>> List(string key)
    {
        var result = await _apiRepository.Queryable().ToTree(it => it.Children, it => it.ParentId, 0);

        
        return _mapper.Map<List<ApiListOutput>>(result);
    }
}